package com.rise.serialportdemo;

import android.view.View;
import android.widget.Button;

import com.rise.serialportdemo.cmd4000.BaseAppCompatActivity;
import com.rise.serialportdemo.led.LedUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * LED测试类
 */
public class LEDActivity extends BaseAppCompatActivity {

    @BindView(R.id.Bn_OpenPort)
    Button Bn_OpenPort;

    @BindView(R.id.Bn_ClosePort)
    Button Bn_ClosePort;

    @BindView(R.id.Bn_OpenBanknoteLamp)
    Button Bn_OpenBanknoteLamp;

    @BindView(R.id.Bn_OpenMoneyEntry)
    Button Bn_OpenMoneyEntry;

    @BindView(R.id.Bn_OpenPrint)
    Button Bn_OpenPrint;

    @BindView(R.id.Bn_ReSet)
    Button Bn_ReSet;

    private LedUtils ledUtils;

    @Override
    protected void initView() {
        ledUtils = new LedUtils();
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_led_text;
    }

    @OnClick({R.id.Bn_OpenPort, R.id.Bn_ClosePort, R.id.Bn_OpenBanknoteLamp,R.id.Bn_OpenMoneyEntry,R.id.Bn_OpenPrint,R.id.Bn_ReSet})
    public void onClickView(View view) {
        switch (view.getId()) {
            case R.id.Bn_OpenPort://打开串口
                ledUtils.BnOpenPort();
                break;
            case R.id.Bn_ClosePort://关闭串口
                ledUtils.BnClosePort();
                break;
            case R.id.Bn_OpenBanknoteLamp://打开出钞灯
                ledUtils.BnCtrlLed(3,1,20,40);
                break;
            case R.id.Bn_OpenMoneyEntry://打开入钞灯
                ledUtils.BnCtrlLed(2,1,20,40);
                break;
            case R.id.Bn_OpenPrint://打开打印机灯
                ledUtils.BnCtrlLed(1,1,20,40);
                break;
            case R.id.Bn_ReSet://重置复位
                ledUtils.BnReSet();
                break;
        }
    }
}
